# 持久化保存 文件
#list 元组，字典--> 内存

#用户注册
def register():
    username = input("请输入用户名：")
    password = input("请输入密码：")
    repassword = input("输入确认密码：")

    if password == repassword:
        # 保存信息
        with open(r'E:\book\user.txt','a') as wstream:
            wstream.write('{} {}\n'.format(username,password))
        print("注册成功！")
    else:
        print("两次密码不一致，请重新输入！")
#用户登入
def login():
    username = input("请输入用户名：")
    password = input("请输入密码：")
    if username and password:
        with open(r'E:\book\user.txt') as rstream:
            while True:
                user = rstream.readline()
                if not user:
                    print("用户名或密码错误！")
                    break

                input_user = '{} {}\n'.format(username,password)
                if user == input_user:
                    print("登入成功！")
                    break

def show_book():
    print('----图书馆里的书有：----')
    with open(r'E:\book\book.txt','r') as rstream:
        books = rstream.readlines()
        for book in books:
            print(book,end = '')
# 调用函数
# register()
# login()
show_book()